﻿<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    assembly="JSC.Portal.Core" namespace="JSC.Portal.Entities">

	<class name="ModuleType" table="jsc_moduletype" lazy="false">

		<!-- start Base on every entity -->
		<id name="Id" column="moduletypeid" unsaved-value="-1">
			<generator class="native">
				<param name="sequence">jsc_moduletype_moduletypeid_seq</param>
			</generator>
		</id>

		<property name="Name" column="name" not-null="true"/>
		<property name="Description" column="description"/>
		<!-- end Base on every entity -->

		<property name="AssemblyName" column="assemblyname" not-null="true"/>
		<property name="ClassName" column="classname" not-null="true"/>
		<property name="ControllerName" column="controllername" not-null="true"/>
    <property name="ViewName" column="viewname" not-null="true"/>

    <bag name="Sections"
				 table="jsc_section"
         cascade="none"
         inverse="true"
         lazy="true">
      <key column="moduletypeid" />
      <one-to-many class="Section"
                   not-found="ignore" />
    </bag>

    <bag name="ModuleProperties" 
         table="jsc_moduleproperty" 
         inverse="true" 
         lazy="true"
         cascade="all">
			<key column="moduletypeid" />
      <one-to-many class="ModuleProperty" 
                   not-found="ignore"/>
		</bag>

    <bag name="LicensedSites"
         table="jsc_sitelicense"
         lazy="true"
         cascade="all">
      <key column="moduletypeid" />
      <composite-element class="SiteLicense">
        <parent name="LicensedModule" />
        <property name="Licensed" column="licensed" type="Boolean" />
        <many-to-one name="PortalSite" class="PortalSite" column="siteid" cascade="none" />
      </composite-element>
    </bag>
		
	</class>
</hibernate-mapping>